<?php
include $_SERVER['DOCUMENT_ROOT'] . '/quocha/lib/Useradmin.php';
$userOb = new Useradmin();

//Xu ly them xoa
$command = '';
$idUsers = '';
$message = array();
if (isset($_GET['command'])) {
    $command = $_GET['command'];
}
if (isset($_GET['idUsers'])) {
    $idUsers = $_GET['idUsers'];
}
if ($command == 'del') {
    if ($userOb->xoaThanhVien($idUsers)) {
        $message[] = "Xóa thành công";
    } else {
        $message[] = "Xóa thất bại";
    }
}

$dsThanhVien = $userOb->layDanhSachThanhVien();
//-------------------
?>

<div class="grid_10">
    <div class="box round first grid">
        <?php foreach ($message as $mes): ?>
        <div class="message success">
        <p><?php echo $mes; ?></p>
         </div>
        <?php endforeach; ?>
        <h2>
            Quản lý tài khoản</h2>
        <div class="block">

            <table class="data display datatable" id="example">

                <thead>
                    <tr>
                        <th>Id</th>
                        <th>Tên tài khoản</th>
                        <th>Mật khẩu</th>
                        <th>Email</th>
                        <th>Điện thoại</th>
                        <th>Họ</th>
                        <th>Tên</th>
                        <th>Nơi ở</th>
                        <th>Loai User</th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($dsThanhVien as $thanhvien): ?>
                        <tr class="odd gradeX">
                            <td><?php echo $thanhvien['idUsers'] ?></td>
                            <td><?php echo $thanhvien['UserName'] ?></td>
                            <td><?php echo $thanhvien['Pass'] ?></td>
                            <td><?php echo $thanhvien['Email'] ?></td>
                            <td><?php echo $thanhvien['PhoneNum'] ?></td>
                            <td><?php echo $thanhvien['LastName'] ?></td>
                            <td><?php echo $thanhvien['FirstName'] ?></td>
                            <td><?php echo $thanhvien['DiaChi'] ?></td>
                            <td><?php echo $thanhvien['Loai_User'] ?></td>
                            <td class="center"><?php echo "<a href='/quocha/admin/index.php?command=del&idUsers=" . $thanhvien['idUsers'] . "'>Xóa"; ?></td>
                            <td class="center"><?php echo "<a href='/quocha/admin/suathanhvien.php?command=edit&idUsers=" . $thanhvien['idUsers'] . "'>Sửa"; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>

